﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmListFuncionario : Form
    {
        private FuncionarioBL bl = new FuncionarioBL();
        private CargoBL cl = new CargoBL();

        public FrmListFuncionario()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadFuncionario c = new FrmCadFuncionario(bl);
            c.ShowDialog();
            funcionarioBindingSource.DataSource = bl.selecionar();
         
        }

        private void FrmListFuncionario_Load(object sender, EventArgs e)
        {
            //cargoBindingSource.DataSource = cl.selecionar();
            funcionarioBindingSource.DataSource = bl.selecionar();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = true;
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = false;

           // funcionarioBindingSource.DataSource = bl.selecionar(txtDesc.Text);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadFuncionario c = new FrmCadFuncionario(bl, ((funcionario)funcionarioBindingSource.Current));
            c.ShowDialog();
            funcionarioBindingSource.DataSource = bl.selecionar();
        }

        private void dtGrdVwBloco_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
                toolStripButton2_Click(null, new EventArgs());
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                bl.excluir((funcionario)funcionarioBindingSource.Current);
                funcionarioBindingSource.DataSource = bl.selecionar();
            }
        }
    }
}
